<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p id="p">x</p>

    <!--查看类型-->
    <script>
        var x = "sdf";
        var y = new String("来");
        document.getElementById("p").innerHTML = typeof x + " " + typeof y;

    </script>


    <!--属性添加-->
    <script>
        function feng(name, age) {
            this.name = name;
            this.age = age;
        }

        var gh = new feng("张三", 18);
        feng.prototype.salary = null;
        gh.salary = 20000.0;
        document.writeln(gh.salary);
    </script><br><br>


    <!--for in-->
    <button onclick="forin()">for in</button>
    <p id="p2">for in</p>
    <script>
        function forin() {
            var x;
            var txt = "";
            var person = { name: "张三", age: 18 };
            for (x in person) {
                txt = txt + person[x];
            }
            document.getElementById("p2").innerHTML = txt;
        }
    </script>


    <!--析字符串-->
    <button onclick="parse()">parse</button>
    <p id="p3">析字符串</p>
    <script>
        function parse() {
            var str = "15.677";
            var int01 = parseInt(str);
            document.getElementById("p3").innerText = int01;
        }
    </script>

    <!--搜索、正则表达式-->
    <p>搜索字符串 "正则", 并显示匹配的起始位置：</p>
    <button onclick="myFunction()">点我</button>
    <p id="demo"></p>
    <script>
    function myFunction() {
        var str ="搜索、正则表达式";
        var num = str.search(/正则/);
        document.getElementById("demo").innerHTML = num;
    }
    </script>

</body>

</html>